namespace YM {
    export class AudioMgr {
        public async playEffect(url: string, loop: boolean) {
            let clip = await game.res.loadAsync(url, cc.AudioClip);
            return cc.audioEngine.playEffect(clip, loop);
        }
        public async playMusic(url: string, loop: boolean) {
            let clip = await game.res.loadAsync(url, cc.AudioClip);
            return cc.audioEngine.playMusic(clip, loop);
        }
        
        private _MusicVolume : number;
        public get MusicVolume() : number {
            return cc.audioEngine.getMusicVolume();
        }
        public set MusicVolume(v : number) {
            cc.audioEngine.setMusicVolume(v);
        }
        
        private _EffectVolume : number;
        public get EffectVolume() : number {
            return cc.audioEngine.getEffectsVolume();
        }
        public set EffectVolume(v : number) {
            cc.audioEngine.setEffectsVolume(v);
        }
        
        public setEffectMute(mute: boolean): void {
            this.EffectVolume=mute?0:1;
        }
        public setMusicMute(mute: boolean): void {
            this.MusicVolume=mute?0:1;
        }
        public setMute(mute: boolean): void {
            this.setEffectMute(mute);
            this.setMusicMute(mute);
        }
        public resumeMusic(){
            cc.audioEngine.resumeMusic();
        }
        public pauseMusic(){
            cc.audioEngine.pauseMusic();
        }
        public stopMusic() {
            cc.audioEngine.stopMusic();
        }
        public resumeEffect(id:number){
            cc.audioEngine.resumeEffect(id);
        }
        public pauseEffect(id:number){
            cc.audioEngine.pauseEffect(id);
        }
        public stopEffect(id:number) {
            cc.audioEngine.stopEffect(id);
        }
    }
}